package com.xique.door.controller;

import com.xique.common.core.domain.R;
import com.xique.common.core.web.domain.PageResult;
import com.xique.common.security.annotation.PreAuthorize;
import com.xique.door.bean.domain.ResourceBit;
import com.xique.door.service.IResourceBitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 资源管理
 */
@RestController
@RequestMapping("/resourceBit")
public class ResourceBitContorller {

    @Autowired
    private IResourceBitService resourceBitService;

    /**
     * 资源列表
     */
    @PreAuthorize(hasPermi = "door:resourceBit:list")
    @GetMapping("/getResourceBitList")
    public PageResult getResourceBitList(
            ResourceBit resourceBit,
            String startTime,
            String endTime,
            Integer pageNum,
            Integer pageSize,
            String userName,
            String exhibitionStatus) {
        return resourceBitService.getResourceBitList(
                resourceBit, startTime, endTime, pageNum, pageSize, userName, exhibitionStatus);
    }

    /**
     * 添加资源
     */
    @PreAuthorize(hasPermi = "door:resourceBit:add")
    @PostMapping("insertResourceBit")
    public R insertResourceBit(@RequestBody ResourceBit resourceBit) {
        return resourceBitService.insertResourceBit(resourceBit);
    }

    /**
     * 资源详情
     */
    @PreAuthorize(hasPermi = "door:resourceBit:edit")
    @GetMapping("/getResourceBit")
    public R getResourceBit(Long id) {
        return resourceBitService.getResourceBit(id);
    }

    /**
     * 资源管理修改
     */
    @PreAuthorize(hasPermi = "door:resourceBit:edit")
    @PutMapping("/updateResourceBit")
    public R updateResourceBit(@RequestBody ResourceBit resourceBit) {
        return resourceBitService.updateResourceBit(resourceBit);
    }

    /**
     * 资源管理状态修改
     */
    @PreAuthorize(hasPermi = "door:resourceBit:edit")
    @PutMapping("/updateStatus")
    public R updateStatus(@RequestBody ResourceBit resourceBit) {
        return resourceBitService.updateStatus(resourceBit.getId(), resourceBit.getStatus());
    }

    /**
     * 资源管理删除
     */
    @PreAuthorize(hasPermi = "door:resourceBit:delete")
    @GetMapping("/deleteResourceBit")
    public R deleteResourceBit(Long id) {
        return resourceBitService.deleteResourceBit(id);
    }




}
